home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / zapem-0.000 / zapem-0 / zapem / gif.h < prev    next >
C/C++ Source or Header  |  1995-06-03  |  2KB  |  84 lines

  1.  
  2. extern "C" {
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. }
  6.  
  7. typedef int boolean;
  8. typedef unsigned char byte;
  9.  
  10. #define NEXTBYTE (*ptr++)
  11. #define IMAGESEP 0x2c
  12. #define INTERLACEMASK 0x40
  13. #define COLORMAPMASK 0x80
  14. #define False 0
  15. #define True 1
  16. #define    FatalError(s)    {fprintf(stderr,"Fatal Error: %s\n",(s)); exit(1);}
  17.  
  18. class Gif {
  19.  
  20. private:
  21.  
  22. FILE *fp;
  23.  
  24. int BitOffset ,            /* Bit Offset of next code */
  25.     XC , YC ,            /* Output X and Y coords of current pixel */
  26.     Pass ,            /* Used by output routine if interlaced pic */
  27.     OutCount ,            /* Decompressor output 'stack count' */
  28.     RWidth, RHeight,        /* screen dimensions */
  29.     Width, Height,        /* image dimensions */
  30.     LeftOfs, TopOfs,        /* image offset */
  31.     BitsPerPixel,        /* Bits per pixel, read from GIF header */
  32.     BytesPerScanline,        /* bytes per scanline in output raster */
  33.     ColorMapSize,        /* number of colors */
  34.     Background,            /* background color */
  35.     CodeSize,            /* Code size, read from GIF header */
  36.     InitCodeSize,        /* Starting code size, used during Clear */
  37.     Code,            /* Value returned by ReadCode */
  38.     MaxCode,            /* limiting value for current code size */
  39.     ClearCode,            /* GIF clear code */
  40.     EOFCode,            /* GIF end-of-information code */
  41.     CurCode, OldCode, InCode,    /* Decompressor variables */
  42.     FirstFree,            /* First free code, generated per GIF spec */
  43.     FreeCode,            /* Decompressor, next free slot in hash table */
  44.     FinChar,            /* Decompressor variable */
  45.     BitMask,            /* AND mask for data size */
  46.     ReadMask;            /* Code AND mask for current code size */
  47.     
  48. boolean Interlace, HasColormap;
  49. boolean Verbose;
  50.  
  51. byte *Image;            /* The address of the start of image data */    
  52. byte *RawGIF;            /* The heap array to hold it, raw */
  53. byte *Raster;            /* The raster data stream, unblocked */
  54.  
  55.     /* The hash table used by the decompressor */
  56. int Prefix[4096];
  57. int Suffix[4096];
  58.  
  59.     /* An output array used by the decompressor */
  60. int OutCode[1025];
  61.  
  62.     /* The color map, read from the GIF header */
  63. byte Red[256], Green[256], Blue[256], used[256];
  64. int  numused,numcols;
  65.  
  66. static char *id;
  67.  
  68.     int ReadCode(void);
  69.     void AddToPixel(byte Index);
  70. public:
  71.     Gif(void){BitOffset = 0; XC = 0; YC = 0; Pass = 0; OutCount = 0;Verbose=False;}        
  72.     void Load(const char *fname);
  73.     void Load(FILE *fileptr);
  74.     void SetPalette(Palette &p);
  75.  
  76.     /* Data access methods */
  77.     byte *getPtr(void){ return Image;}
  78.     int getWidth(void){ return Width;}
  79.     int getHeight(void){ return Height;}
  80.  
  81. }; //end of class Gif
  82.  
  83.  
  84.